define([
'react',
'js/myUtil.js'
], function(React,myUtil) {
	var MyWidget = React.createClass({
		render: function() {
			return (
	          <form className="commentForm" onSubmit={this.handleSubmit}>
	            <input type="text" ref="name" placeholder="Your name" /><br/>
	            <input type="password" ref="password" placeholder="password" /><br/>
	            <input type="submit" value="login" />
	          </form>
			);
		},

		handleSubmit: function(event) {
			event.preventDefault();
			var name = this.refs.name.value.trim();
        	var password = this.refs.password.value.trim();
        	console.log(name,password);

			var formData ={name:name, password:password};
			myUtil.login(formData, function(err, res) {
				console.log(res);
				if (err) return nodeTip.text(err).show();
				if (res.errCode !== 0) return nodeTip.text(res.errMsg).show();

				// all sucess;
				console.log('succ');
				window.location.href = "#forum/thread";
			});
		}
	});
	return MyWidget;
});